\(\int \cos ^2(c+d x) (a+b \tan (c+d x))^3 \, dx\) [535]

   Optimal result
   Rubi [A] (verified)
   Mathematica [B] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [F]
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 21, antiderivative size = 86 \[ \int \cos ^2(c+d x) (a+b \tan (c+d x))^3 \, dx=\frac {1}{2} a \left (a^2+3 b^2\right ) x-\frac {b^3 \log (\cos (c+d x))}{d}-\frac {a b^2 \tan (c+d x)}{2 d}-\frac {\cos ^2(c+d x) (b-a \tan (c+d x)) (a+b \tan (c+d x))^2}{2 d} \]

[Out]

1/2*a*(a^2+3*b^2)*x-b^3*ln(cos(d*x+c))/d-1/2*a*b^2*tan(d*x+c)/d-1/2*cos(d*x+c)^2*(b-a*tan(d*x+c))*(a+b*tan(d*x
+c))^2/d

Rubi [A] (verified)

Time = 0.13 (sec) , antiderivative size = 86, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.286, Rules used = {3587, 753, 788, 649, 209, 266} \[ \int \cos ^2(c+d x) (a+b \tan (c+d x))^3 \, dx=\frac {1}{2} a x \left (a^2+3 b^2\right )-\frac {a b^2 \tan (c+d x)}{2 d}-\frac {\cos ^2(c+d x) (b-a \tan (c+d x)) (a+b \tan (c+d x))^2}{2 d}-\frac {b^3 \log (\cos (c+d x))}{d} \]

[In]

Int[Cos[c + d*x]^2*(a + b*Tan[c + d*x])^3,x]

[Out]

(a*(a^2 + 3*b^2)*x)/2 - (b^3*Log[Cos[c + d*x]])/d - (a*b^2*Tan[c + d*x])/(2*d) - (Cos[c + d*x]^2*(b - a*Tan[c
+ d*x])*(a + b*Tan[c + d*x])^2)/(2*d)

Rule 209

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*ArcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 266

Int[(x_)^(m_.)/((a_) + (b_.)*(x_)^(n_)), x_Symbol] :> Simp[Log[RemoveContent[a + b*x^n, x]]/(b*n), x] /; FreeQ
[{a, b, m, n}, x] && EqQ[m, n - 1]

Rule 649

Int[((d_) + (e_.)*(x_))/((a_) + (c_.)*(x_)^2), x_Symbol] :> Dist[d, Int[1/(a + c*x^2), x], x] + Dist[e, Int[x/
(a + c*x^2), x], x] /; FreeQ[{a, c, d, e}, x] &&  !NiceSqrtQ[(-a)*c]

Rule 753

Int[((d_) + (e_.)*(x_))^(m_)*((a_) + (c_.)*(x_)^2)^(p_), x_Symbol] :> Simp[(d + e*x)^(m - 1)*(a*e - c*d*x)*((a
 + c*x^2)^(p + 1)/(2*a*c*(p + 1))), x] + Dist[1/((p + 1)*(-2*a*c)), Int[(d + e*x)^(m - 2)*Simp[a*e^2*(m - 1) -
 c*d^2*(2*p + 3) - d*c*e*(m + 2*p + 2)*x, x]*(a + c*x^2)^(p + 1), x], x] /; FreeQ[{a, c, d, e}, x] && NeQ[c*d^
2 + a*e^2, 0] && LtQ[p, -1] && GtQ[m, 1] && IntQuadraticQ[a, 0, c, d, e, m, p, x]

Rule 788

Int[(((d_.) + (e_.)*(x_))*((f_) + (g_.)*(x_)))/((a_) + (c_.)*(x_)^2), x_Symbol] :> Simp[e*g*(x/c), x] + Dist[1
/c, Int[(c*d*f - a*e*g + c*(e*f + d*g)*x)/(a + c*x^2), x], x] /; FreeQ[{a, c, d, e, f, g}, x]

Rule 3587

Int[sec[(e_.) + (f_.)*(x_)]^(m_)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Dist[1/(b*f), Subst
[Int[(a + x)^n*(1 + x^2/b^2)^(m/2 - 1), x], x, b*Tan[e + f*x]], x] /; FreeQ[{a, b, e, f, n}, x] && NeQ[a^2 + b
^2, 0] && IntegerQ[m/2]

Rubi steps \begin{align*} \text {integral}& = \frac {\text {Subst}\left (\int \frac {(a+x)^3}{\left (1+\frac {x^2}{b^2}\right )^2} \, dx,x,b \tan (c+d x)\right )}{b d} \\ & = -\frac {\cos ^2(c+d x) (b-a \tan (c+d x)) (a+b \tan (c+d x))^2}{2 d}+\frac {b \text {Subst}\left (\int \frac {(a+x) \left (2+\frac {a^2}{b^2}-\frac {a x}{b^2}\right )}{1+\frac {x^2}{b^2}} \, dx,x,b \tan (c+d x)\right )}{2 d} \\ & = -\frac {a b^2 \tan (c+d x)}{2 d}-\frac {\cos ^2(c+d x) (b-a \tan (c+d x)) (a+b \tan (c+d x))^2}{2 d}+\frac {b^3 \text {Subst}\left (\int \frac {\frac {a}{b^2}+\frac {a \left (2+\frac {a^2}{b^2}\right )}{b^2}+\frac {2 x}{b^2}}{1+\frac {x^2}{b^2}} \, dx,x,b \tan (c+d x)\right )}{2 d} \\ & = -\frac {a b^2 \tan (c+d x)}{2 d}-\frac {\cos ^2(c+d x) (b-a \tan (c+d x)) (a+b \tan (c+d x))^2}{2 d}+\frac {b \text {Subst}\left (\int \frac {x}{1+\frac {x^2}{b^2}} \, dx,x,b \tan (c+d x)\right )}{d}+\frac {\left (a \left (a^2+3 b^2\right )\right ) \text {Subst}\left (\int \frac {1}{1+\frac {x^2}{b^2}} \, dx,x,b \tan (c+d x)\right )}{2 b d} \\ & = \frac {1}{2} a \left (a^2+3 b^2\right ) x-\frac {b^3 \log (\cos (c+d x))}{d}-\frac {a b^2 \tan (c+d x)}{2 d}-\frac {\cos ^2(c+d x) (b-a \tan (c+d x)) (a+b \tan (c+d x))^2}{2 d} \\ \end{align*}

Mathematica [B] (verified)

Leaf count is larger than twice the leaf count of optimal. \(401\) vs. \(2(86)=172\).

Time = 0.84 (sec) , antiderivative size = 401, normalized size of antiderivative = 4.66 \[ \int \cos ^2(c+d x) (a+b \tan (c+d x))^3 \, dx=\frac {5 a^4 b^2+2 a^2 b^4-b^6+\left (-3 a^4 b^2-2 a^2 b^4+b^6\right ) \cos (2 (c+d x))+2 a^2 b^4 \log \left (\sqrt {-b^2}-b \tan (c+d x)\right )+2 b^6 \log \left (\sqrt {-b^2}-b \tan (c+d x)\right )-a^5 \sqrt {-b^2} \log \left (\sqrt {-b^2}-b \tan (c+d x)\right )+4 a^3 \left (-b^2\right )^{3/2} \log \left (\sqrt {-b^2}-b \tan (c+d x)\right )-3 a \left (-b^2\right )^{5/2} \log \left (\sqrt {-b^2}-b \tan (c+d x)\right )+2 a^2 b^4 \log \left (\sqrt {-b^2}+b \tan (c+d x)\right )+2 b^6 \log \left (\sqrt {-b^2}+b \tan (c+d x)\right )+a^5 \sqrt {-b^2} \log \left (\sqrt {-b^2}+b \tan (c+d x)\right )+3 a b^4 \sqrt {-b^2} \log \left (\sqrt {-b^2}+b \tan (c+d x)\right )-4 a^3 \left (-b^2\right )^{3/2} \log \left (\sqrt {-b^2}+b \tan (c+d x)\right )+a b \left (a^4-2 a^2 b^2-3 b^4\right ) \sin (2 (c+d x))}{4 b \left (a^2+b^2\right ) d} \]

[In]

Integrate[Cos[c + d*x]^2*(a + b*Tan[c + d*x])^3,x]

[Out]

(5*a^4*b^2 + 2*a^2*b^4 - b^6 + (-3*a^4*b^2 - 2*a^2*b^4 + b^6)*Cos[2*(c + d*x)] + 2*a^2*b^4*Log[Sqrt[-b^2] - b*
Tan[c + d*x]] + 2*b^6*Log[Sqrt[-b^2] - b*Tan[c + d*x]] - a^5*Sqrt[-b^2]*Log[Sqrt[-b^2] - b*Tan[c + d*x]] + 4*a
^3*(-b^2)^(3/2)*Log[Sqrt[-b^2] - b*Tan[c + d*x]] - 3*a*(-b^2)^(5/2)*Log[Sqrt[-b^2] - b*Tan[c + d*x]] + 2*a^2*b
^4*Log[Sqrt[-b^2] + b*Tan[c + d*x]] + 2*b^6*Log[Sqrt[-b^2] + b*Tan[c + d*x]] + a^5*Sqrt[-b^2]*Log[Sqrt[-b^2] +
 b*Tan[c + d*x]] + 3*a*b^4*Sqrt[-b^2]*Log[Sqrt[-b^2] + b*Tan[c + d*x]] - 4*a^3*(-b^2)^(3/2)*Log[Sqrt[-b^2] + b
*Tan[c + d*x]] + a*b*(a^4 - 2*a^2*b^2 - 3*b^4)*Sin[2*(c + d*x)])/(4*b*(a^2 + b^2)*d)

Maple [A] (verified)

Time = 4.70 (sec) , antiderivative size = 98, normalized size of antiderivative = 1.14

method result size
derivativedivides \(\frac {b^{3} \left (-\frac {\left (\sin ^{2}\left (d x +c \right )\right )}{2}-\ln \left (\cos \left (d x +c \right )\right )\right )+3 a \,b^{2} \left (-\frac {\sin \left (d x +c \right ) \cos \left (d x +c \right )}{2}+\frac {d x}{2}+\frac {c}{2}\right )-\frac {3 a^{2} b \left (\cos ^{2}\left (d x +c \right )\right )}{2}+a^{3} \left (\frac {\sin \left (d x +c \right ) \cos \left (d x +c \right )}{2}+\frac {d x}{2}+\frac {c}{2}\right )}{d}\) \(98\)
default \(\frac {b^{3} \left (-\frac {\left (\sin ^{2}\left (d x +c \right )\right )}{2}-\ln \left (\cos \left (d x +c \right )\right )\right )+3 a \,b^{2} \left (-\frac {\sin \left (d x +c \right ) \cos \left (d x +c \right )}{2}+\frac {d x}{2}+\frac {c}{2}\right )-\frac {3 a^{2} b \left (\cos ^{2}\left (d x +c \right )\right )}{2}+a^{3} \left (\frac {\sin \left (d x +c \right ) \cos \left (d x +c \right )}{2}+\frac {d x}{2}+\frac {c}{2}\right )}{d}\) \(98\)
risch \(i x \,b^{3}+\frac {a^{3} x}{2}+\frac {3 x a \,b^{2}}{2}-\frac {3 \,{\mathrm e}^{2 i \left (d x +c \right )} b \,a^{2}}{8 d}+\frac {{\mathrm e}^{2 i \left (d x +c \right )} b^{3}}{8 d}-\frac {i {\mathrm e}^{2 i \left (d x +c \right )} a^{3}}{8 d}+\frac {3 i {\mathrm e}^{2 i \left (d x +c \right )} a \,b^{2}}{8 d}-\frac {3 \,{\mathrm e}^{-2 i \left (d x +c \right )} b \,a^{2}}{8 d}+\frac {{\mathrm e}^{-2 i \left (d x +c \right )} b^{3}}{8 d}+\frac {i {\mathrm e}^{-2 i \left (d x +c \right )} a^{3}}{8 d}-\frac {3 i {\mathrm e}^{-2 i \left (d x +c \right )} a \,b^{2}}{8 d}+\frac {2 i b^{3} c}{d}-\frac {b^{3} \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}{d}\) \(196\)

[In]

int(cos(d*x+c)^2*(a+b*tan(d*x+c))^3,x,method=_RETURNVERBOSE)

[Out]

1/d*(b^3*(-1/2*sin(d*x+c)^2-ln(cos(d*x+c)))+3*a*b^2*(-1/2*sin(d*x+c)*cos(d*x+c)+1/2*d*x+1/2*c)-3/2*a^2*b*cos(d
*x+c)^2+a^3*(1/2*sin(d*x+c)*cos(d*x+c)+1/2*d*x+1/2*c))

Fricas [A] (verification not implemented)

none

Time = 0.26 (sec) , antiderivative size = 79, normalized size of antiderivative = 0.92 \[ \int \cos ^2(c+d x) (a+b \tan (c+d x))^3 \, dx=-\frac {2 \, b^{3} \log \left (-\cos \left (d x + c\right )\right ) - {\left (a^{3} + 3 \, a b^{2}\right )} d x + {\left (3 \, a^{2} b - b^{3}\right )} \cos \left (d x + c\right )^{2} - {\left (a^{3} - 3 \, a b^{2}\right )} \cos \left (d x + c\right ) \sin \left (d x + c\right )}{2 \, d} \]

[In]

integrate(cos(d*x+c)^2*(a+b*tan(d*x+c))^3,x, algorithm="fricas")

[Out]

-1/2*(2*b^3*log(-cos(d*x + c)) - (a^3 + 3*a*b^2)*d*x + (3*a^2*b - b^3)*cos(d*x + c)^2 - (a^3 - 3*a*b^2)*cos(d*
x + c)*sin(d*x + c))/d

Sympy [F]

\[ \int \cos ^2(c+d x) (a+b \tan (c+d x))^3 \, dx=\int \left (a + b \tan {\left (c + d x \right )}\right )^{3} \cos ^{2}{\left (c + d x \right )}\, dx \]

[In]

integrate(cos(d*x+c)**2*(a+b*tan(d*x+c))**3,x)

[Out]

Integral((a + b*tan(c + d*x))**3*cos(c + d*x)**2, x)

Maxima [A] (verification not implemented)

none

Time = 0.29 (sec) , antiderivative size = 81, normalized size of antiderivative = 0.94 \[ \int \cos ^2(c+d x) (a+b \tan (c+d x))^3 \, dx=\frac {b^{3} \log \left (\tan \left (d x + c\right )^{2} + 1\right ) + {\left (a^{3} + 3 \, a b^{2}\right )} {\left (d x + c\right )} - \frac {3 \, a^{2} b - b^{3} - {\left (a^{3} - 3 \, a b^{2}\right )} \tan \left (d x + c\right )}{\tan \left (d x + c\right )^{2} + 1}}{2 \, d} \]

[In]

integrate(cos(d*x+c)^2*(a+b*tan(d*x+c))^3,x, algorithm="maxima")

[Out]

1/2*(b^3*log(tan(d*x + c)^2 + 1) + (a^3 + 3*a*b^2)*(d*x + c) - (3*a^2*b - b^3 - (a^3 - 3*a*b^2)*tan(d*x + c))/
(tan(d*x + c)^2 + 1))/d

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 561 vs. \(2 (81) = 162\).

Time = 0.89 (sec) , antiderivative size = 561, normalized size of antiderivative = 6.52 \[ \int \cos ^2(c+d x) (a+b \tan (c+d x))^3 \, dx=\frac {2 \, a^{3} d x \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + 6 \, a b^{2} d x \tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 2 \, b^{3} \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} + \tan \left (c\right )^{2} + 1}\right ) \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + 2 \, a^{3} d x \tan \left (d x\right )^{2} + 6 \, a b^{2} d x \tan \left (d x\right )^{2} + 2 \, a^{3} d x \tan \left (c\right )^{2} + 6 \, a b^{2} d x \tan \left (c\right )^{2} - 3 \, a^{2} b \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + b^{3} \tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 2 \, b^{3} \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} + \tan \left (c\right )^{2} + 1}\right ) \tan \left (d x\right )^{2} - 2 \, a^{3} \tan \left (d x\right )^{2} \tan \left (c\right ) + 6 \, a b^{2} \tan \left (d x\right )^{2} \tan \left (c\right ) - 2 \, b^{3} \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} + \tan \left (c\right )^{2} + 1}\right ) \tan \left (c\right )^{2} - 2 \, a^{3} \tan \left (d x\right ) \tan \left (c\right )^{2} + 6 \, a b^{2} \tan \left (d x\right ) \tan \left (c\right )^{2} + 2 \, a^{3} d x + 6 \, a b^{2} d x + 3 \, a^{2} b \tan \left (d x\right )^{2} - b^{3} \tan \left (d x\right )^{2} + 12 \, a^{2} b \tan \left (d x\right ) \tan \left (c\right ) - 4 \, b^{3} \tan \left (d x\right ) \tan \left (c\right ) + 3 \, a^{2} b \tan \left (c\right )^{2} - b^{3} \tan \left (c\right )^{2} - 2 \, b^{3} \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} + \tan \left (c\right )^{2} + 1}\right ) + 2 \, a^{3} \tan \left (d x\right ) - 6 \, a b^{2} \tan \left (d x\right ) + 2 \, a^{3} \tan \left (c\right ) - 6 \, a b^{2} \tan \left (c\right ) - 3 \, a^{2} b + b^{3}}{4 \, {\left (d \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + d \tan \left (d x\right )^{2} + d \tan \left (c\right )^{2} + d\right )}} \]

[In]

integrate(cos(d*x+c)^2*(a+b*tan(d*x+c))^3,x, algorithm="giac")

[Out]

1/4*(2*a^3*d*x*tan(d*x)^2*tan(c)^2 + 6*a*b^2*d*x*tan(d*x)^2*tan(c)^2 - 2*b^3*log(4*(tan(d*x)^2*tan(c)^2 - 2*ta
n(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1))*tan(d*x)^2*tan(c)^2 + 2*a^3*d*x*tan(d*x)
^2 + 6*a*b^2*d*x*tan(d*x)^2 + 2*a^3*d*x*tan(c)^2 + 6*a*b^2*d*x*tan(c)^2 - 3*a^2*b*tan(d*x)^2*tan(c)^2 + b^3*ta
n(d*x)^2*tan(c)^2 - 2*b^3*log(4*(tan(d*x)^2*tan(c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^
2 + tan(c)^2 + 1))*tan(d*x)^2 - 2*a^3*tan(d*x)^2*tan(c) + 6*a*b^2*tan(d*x)^2*tan(c) - 2*b^3*log(4*(tan(d*x)^2*
tan(c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1))*tan(c)^2 - 2*a^3*tan(d*x)
*tan(c)^2 + 6*a*b^2*tan(d*x)*tan(c)^2 + 2*a^3*d*x + 6*a*b^2*d*x + 3*a^2*b*tan(d*x)^2 - b^3*tan(d*x)^2 + 12*a^2
*b*tan(d*x)*tan(c) - 4*b^3*tan(d*x)*tan(c) + 3*a^2*b*tan(c)^2 - b^3*tan(c)^2 - 2*b^3*log(4*(tan(d*x)^2*tan(c)^
2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1)) + 2*a^3*tan(d*x) - 6*a*b^2*tan(d
*x) + 2*a^3*tan(c) - 6*a*b^2*tan(c) - 3*a^2*b + b^3)/(d*tan(d*x)^2*tan(c)^2 + d*tan(d*x)^2 + d*tan(c)^2 + d)

Mupad [B] (verification not implemented)

Time = 4.42 (sec) , antiderivative size = 141, normalized size of antiderivative = 1.64 \[ \int \cos ^2(c+d x) (a+b \tan (c+d x))^3 \, dx=\frac {b^3\,\ln \left (\frac {1}{{\cos \left (c+d\,x\right )}^2}\right )}{2\,d}+\frac {b^3\,{\cos \left (c+d\,x\right )}^2}{2\,d}+\frac {a^3\,\mathrm {atan}\left (\frac {\sin \left (c+d\,x\right )}{\cos \left (c+d\,x\right )}\right )}{2\,d}-\frac {3\,a^2\,b\,{\cos \left (c+d\,x\right )}^2}{2\,d}+\frac {3\,a\,b^2\,\mathrm {atan}\left (\frac {\sin \left (c+d\,x\right )}{\cos \left (c+d\,x\right )}\right )}{2\,d}+\frac {a^3\,\cos \left (c+d\,x\right )\,\sin \left (c+d\,x\right )}{2\,d}-\frac {3\,a\,b^2\,\cos \left (c+d\,x\right )\,\sin \left (c+d\,x\right )}{2\,d} \]

[In]

int(cos(c + d*x)^2*(a + b*tan(c + d*x))^3,x)

[Out]

(b^3*log(1/cos(c + d*x)^2))/(2*d) + (b^3*cos(c + d*x)^2)/(2*d) + (a^3*atan(sin(c + d*x)/cos(c + d*x)))/(2*d) -
 (3*a^2*b*cos(c + d*x)^2)/(2*d) + (3*a*b^2*atan(sin(c + d*x)/cos(c + d*x)))/(2*d) + (a^3*cos(c + d*x)*sin(c +
d*x))/(2*d) - (3*a*b^2*cos(c + d*x)*sin(c + d*x))/(2*d)